/*
 * Hidden Equity LLC
 * Author: Maksym Fedyay, Kyiv, mcsimf@gmail.com
 * Date: 29.02.2012
 */

package com.hiddenequity.utils;


public class SOAPUtils {

	/*
	 * Default xml namespaces
	 */
	public static final String XMLNS = "'https://adwords.google.com/api/adwords/cm/v201109' ";
	public static final String XMLNS_MCM = "'https://adwords.google.com/api/adwords/mcm/v201109' ";
	public static final String XMLNSXSI = "'http://www.w3.org/2001/XMLSchema-instance' ";
	public static final String XMLNSSOAP = "'http://schemas.xmlsoap.org/soap/envelope/' ";		
	
	
	
	/*
	 * Build SOAP Header
	 */
	private static String buildHeader(){

		String SOAPHeader =
			"<soap:Header>" +
				"<RequestHeader>" +
					"<authToken>" + AuthService.authToken + "</authToken>" +
					"<userAgent>" + "McSimF-Android-App" + "</userAgent>" +
					"<developerToken>" + AuthService.devToken + "</developerToken>" +
					"<clientEmail>" + AuthService.accountEmail + "</clientEmail>" +
				"</RequestHeader>" +
			"</soap:Header>";
		
		return SOAPHeader;
	}//buildSOAPEnvelopHeader
	
	//"<clientCustomerId>" + AuthService.CustomerId + "</clientCustomerId>" +
	
//	/*
//	 * V13 SOAP header
//	 */
//	private static String buildV13Header(){
//		String SOAPHeader =
//				"<soap:Header>" +
//
//						"<authToken>" + AuthService.authToken + "</authToken>" +
//						"<userAgent>" + "McSimF-Android-App" + "</userAgent>" +
//						"<developerToken>" + AuthService.devToken + "</developerToken>" +
//						"<clientEmail>" + AuthService.accountEmail + "</clientEmail>" +
//					"<soapAction>https://adwords.google.com/api/adwords/v13/AccountService<soapAction>" +
//				"</soap:Header>";
//			
//			return SOAPHeader;
//	}
//	
//	
	/*
	 * Build V13 envelope
	 */
	public static String buildMCMEnvelope(String body){
		
		String SOAPEnvelope = "<?xml version='1.0' encoding='UTF-8'?>" +
				"<soap:Envelope " +
				"xmlns:soap=" + SOAPUtils.XMLNSSOAP +
				" xmlns=" + SOAPUtils.XMLNS_MCM +
 				">" +
					buildHeader() +
					body +
				"</soap:Envelope>";
		return SOAPEnvelope;
		
	}//buildV13Envelope
	
	
	/*
	 *Build SOAP Envelope 
	 */
	public static String buildEnvelope(String body){
		
		String SOAPEnvelope = "<?xml version='1.0' encoding='UTF-8'?>" +
				"<soap:Envelope " +
				"xmlns:soap=" + SOAPUtils.XMLNSSOAP +
				" xmlns=" + SOAPUtils.XMLNS + ">" +
					buildHeader() +
					body +
				"</soap:Envelope>";
		return SOAPEnvelope;
		
	}//buildSOAPEnvelope
	
}
